#include <iostream>
#include <algorithm>
using namespace std;
int n, m, c1, c2;
int e[510][510], weight[510], dis[510], num[510], w[510];
bool vis[510];
const int inf = 0x7fffffff;
int main()
{
    scanf("%d%d%d%d", &n, &m, &c1, &c2);
    for (int i = 0; i < n; i++)
        scanf("%d", &weight[i]);
    fill(e[0], e[0] + 510 * 510, inf);
    fill(dis, dis + 510, inf);
    int a, b, c;
    for (int i = 0; i < m; i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        e[a][b] = e[b][a] = c;
    }
    dis[c1] = 0;
    w[c1] = weight[c1];
    num[c1] = 1;
    for (int i = 0; i < n; ++i)
    {
        int u = -1; //寻找未加入集合中的最近点
        int mindis = inf;
        for (int j = 0; j < n; ++j)
        {
            if (vis[j] == 0 && mindis > dis[j])
            {
                mindis = dis[j];
                u = j;
            }
        }
        if (u == -1)
            break;
        vis[u] = 1;
        for (int v = 0; v < n; ++v)
        {
            if (vis[v] == 0 && e[u][v] != inf)
            {
                if (dis[u] + e[u][v] < dis[v])
                {
                    dis[v] = dis[u] + e[u][v];
                    num[v] = num[u];
                    w[v] = w[u] + weight[v];
                }
                else if(dis[u]+e[u][v]==dis[v]){
                    num[v] += num[u];
                    w[v] = max(w[u] + weight[v], w[v]);
                }
            }
        }
    }
    printf("%d %d", num[c2], w[c2]);
    return 0;
}
